<template>
  <top-header
    :defaultSettings="title"
    :schoolName="schoolName"
    :studentName="studentName"
    :mainSchoolName="mainSchoolName"
    :schoolId="schoolId"
    :msgCenterUrl="msgCenterUrl"
    :imgUploadUrl="imgUploadUrl"
    :unreadMsgCount="number"
    :showMessageCount=false
    @updateUserInfo="updateUserInfo"
    @updatePwd="updatePwd"
    @logout="logout"
    :userInfo="userInfo"
    ref="topHeader"
  > </top-header>
</template>

<script>
  import TopHeader from '../head'
    export default {
      name: "dt",
      components : { TopHeader },
        data () {
          return {

            number : 9,
            title: '123',
            schoolName : 'test School',
            studentName : 'http://v4.test.cotf.cn/cfp',
            mainSchoolName : '',
            schoolId : 'd3746e6564374233bffd66e3612c9924',
            msgCenterUrl : 'http://v4.test.cotf.cn/cfp',
            imgUploadUrl: 'http://v4.test.cotf.cn/pms-ws' + "/busi/upload/img?code=1" ,
          }
        },
      methods: {
        // handleClickOutside() {
        //   this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
        // },
        updateUserInfo(userInfo) {
          updateUserInfo(userInfo).then(res => {
            if (res.code === 200) {
              this.$message({message: "更新成功！", type : "success"});
              this.$refs.topHeader.personDialog = false
              store.dispatch('GetInfo').then(() => {

              });
            } else {
              this.$alert("更新失败！" + res.message, "错误", {type : "error"});
              this.$refs.topHeader.personDialog = false
            }
          });
        },
        updatePwd(params){
          console.log(params)
          // updatePwd(params).then(res => {
          //   if (res.code === 200) {
          //     this.$message({message: "更新成功！", type : "success"});
          //     this.$refs.topHeader.personDialog = false;
          //     this.$refs.topHeader.errorShow = false;
          //   } else {
          //     this.$refs.topHeader.errorShow = true;
          //     this.$refs.topHeader.errorTitle = res.message;
          //   }
          // })
        },
        logout() {
          console.log('hello')
          // logout().then((res) => {
          //   console.log('res' + JSON.stringify(res))
          //   if (res.code === 200) {
          //     window.location.href = res.result + "?service=" + process.env.VUE_APP_DT_HOME;
          //   } else {
          //     this.$message.error(res.message);
          //   }
          // });
        },
        // unreadMsgCountAction () {
        //   clearInterval(window.intervalId);
        //   if (this.showMessageCount) {
        //     let params = {
        //       userId : this.userInfo.id,
        //       schoolId : this.schoolId
        //     }
        //     unreadMsgCount(params).then(res => {
        //       this.number = res.result > 99 ? 99 : res.result
        //       this.number = res.result ? res.result > 99 ? 99 : res.result : 0;
        //     })
        //     window.intervalId = setInterval(this.unreadMsgCountAction, 120000);
        //   } else {
        //     return ;
        //   }
        //
        // } ,
      },
    }
</script>

<style scoped>

</style>
